package org.example.innovate.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.example.innovate.common.CommonResponse;
import org.example.innovate.domain.IngredientsInventory;
import org.example.innovate.service.IngredientsInventoryService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/ingredient")
@Valid
public class IngredientsInventoryController {
    @Resource
    IngredientsInventoryService ingredientsInventoryService;

    @GetMapping("/get")
    public CommonResponse<List<IngredientsInventory>> get(HttpServletRequest req) {
        return ingredientsInventoryService.get(req);
    }

    @PostMapping("/add")
    public CommonResponse<IngredientsInventory> add(@Validated @RequestBody IngredientsInventory ingredientsInventory,HttpServletRequest req) {
        return ingredientsInventoryService.add(req,ingredientsInventory);
    }

    @PostMapping("/update")
    public CommonResponse<List<IngredientsInventory>> update(@Validated @RequestBody List<IngredientsInventory> ingredientsInventorys,HttpServletRequest req) {
        return ingredientsInventoryService.update(ingredientsInventorys,req);
    }

    @PostMapping("/delete")
    public CommonResponse<IngredientsInventory> delete(@RequestBody IngredientsInventory ingredientsInventory,HttpServletRequest req) {
        return ingredientsInventoryService.delete(ingredientsInventory);
    }
}
